//
//  FruitCommentOrderViewController.m
//  HuiMWorld
//
//  Created by chirui on 2018/3/26.
//  Copyright © 2018年 Shui. All rights reserved.
//

#import "FruitCommentOrderViewController.h"

@interface FruitCommentOrderViewController ()

@property (nonatomic,strong) SZTextView * sztTextView;

@end

@implementation FruitCommentOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    self.view.backgroundColor =[UIColor groupTableViewBackgroundColor];
    
    self.navigationItem.titleView = [TopLabel withLabelWithLabelText:@"评价描述"];
    [self creatTextView];
    
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem rightItemWithTitle:@"提交" target:self action:@selector(sumBtnClick)];
    
}

- (void)creatTextView {
    
    
    self.sztTextView =[[SZTextView alloc]initWithFrame:CGRectMake(0, 10, WIDTH, 300)];
    self.sztTextView.placeholder = @"请输入评价内容";
    self.sztTextView.font =[UIFont systemFontOfSize:15];
    [self.view addSubview:self.sztTextView];
}

-(void)sumBtnClick {
    
    [self.sztTextView resignFirstResponder];
    
    if (self.sztTextView.text.length<=0) {
        
        [MBProgressHUD showMessag:@"请输入评论内容" withDelay:0 toView:self.view withMode:MBProgressHUDModeText hideWithDelay:1.5];
        return;
    }else {
            [self requestMessageForNet];
    }
}

-(void)requestMessageForNet{
    
    NSDictionary * dic = @{@"user_id":USER_DEFAULTGet(@"user_id"),
                           @"token":USER_DEFAULTGet(@"token"),
                           @"content":self.sztTextView.text,
                           @"order_id":self.dataDic[@"order_id"],
                           @"shop_id":self.dataDic[@"shop_id"]
                           };
    SHuiMBhubNoTimeStr(@"正在提交...");
    [PostNetWorking postNetWorkingStr:RequestUrlStr(comment_sellOrder_api) andparameters:dic Success:^(id responseObject) {
        SHuiMBHidleYes;
        if (codeSucess) {
            SHuiMBhudTextTimeStr(@"提交成功！");
            dispatch_async(dispatch_get_global_queue(0, 0), ^{
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW , (1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(),^{
                    
                    [self.navigationController popViewControllerAnimated:YES];
                });
            });
        }else {
            
            SHuiMBhudTextTimeStr(responseObject[@"mark"]);
        }
        
    } failed:^(NSError *error) {
        SHuiMBHidleYes;
        SHuiMBhudTextNetError;
    }];
    
}

@end
